/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.volume.Volume;
/*    */ import com.zimbra.cs.volume.Volume.Builder;
/*    */ import com.zimbra.cs.volume.VolumeManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.ModifyVolumeRequest;
/*    */ import com.zimbra.soap.admin.message.ModifyVolumeResponse;
/*    */ import com.zimbra.soap.admin.type.VolumeInfo;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class ModifyVolume
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element req, Map<String, Object> ctx)
/*    */     throws ServiceException
/*    */   {
/* 40 */     ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
/* 41 */     return zsc.jaxbToElement(handle((ModifyVolumeRequest)JaxbUtil.elementToJaxb(req), ctx));
/*    */   }
/*    */   
/*    */   private ModifyVolumeResponse handle(ModifyVolumeRequest req, Map<String, Object> ctx) throws ServiceException {
/* 45 */     ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
/* 46 */     checkRight(zsc, ctx, Provisioning.getInstance().getLocalServer(), Rights.Admin.R_manageVolume);
/*    */     
/* 48 */     VolumeManager mgr = VolumeManager.getInstance();
/* 49 */     Volume.Builder builder = Volume.builder(mgr.getVolume(req.getId()));
/* 50 */     VolumeInfo vol = req.getVolume();
/* 51 */     if (vol == null) {
/* 52 */       throw ServiceException.INVALID_REQUEST("must specify a volume Element", null);
/*    */     }
/* 54 */     if (vol.getType() > 0) {
/* 55 */       builder.setType(vol.getType());
/*    */     }
/* 57 */     if (vol.getName() != null) {
/* 58 */       builder.setName(vol.getName());
/*    */     }
/* 60 */     if (vol.getRootPath() != null) {
/* 61 */       builder.setPath(vol.getRootPath(), true);
/*    */     }
/* 63 */     if (vol.getCompressBlobs() != null) {
/* 64 */       builder.setCompressBlobs(vol.getCompressBlobs().booleanValue());
/*    */     }
/* 66 */     if (vol.getCompressionThreshold() > 0L) {
/* 67 */       builder.setCompressionThreshold(vol.getCompressionThreshold());
/*    */     }
/* 69 */     mgr.update(builder.build());
/* 70 */     return new ModifyVolumeResponse();
/*    */   }
/*    */   
/*    */ 
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 76 */     relatedRights.add(Rights.Admin.R_manageVolume);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/ModifyVolume.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */